package com.csy.ocmis.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.csy.ocmis.entity.Report;
import com.csy.ocmis.entity.ReportVo;
import com.csy.ocmis.mapper.CashierMapper;
import com.csy.ocmis.mapper.ReportMapper;
import com.csy.ocmis.service.IReportService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author csy
 * @since 2020-11-29
 */
@Service
public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements IReportService {
    @Resource
    private ReportMapper reportMapper;
    @Resource
    private CashierMapper cashierMapper;
    @Override
    public int upddang() {
        return reportMapper.upddang();
    }


    //查询挂号的所有信息
    @Override
    public List<ReportVo> sel(ReportVo reportVo) {
        return reportMapper.sel(reportVo);
    }

    @Override
    public int checkPhone(String phone) {
        QueryWrapper<Report> wrapper = new QueryWrapper<>();
        wrapper.eq("phone",phone);
        wrapper.eq("time",new Date());
        return reportMapper.selectCount(wrapper);
    }

    @Override
    public int checkCarId(String carid) {
        QueryWrapper<Report> wrapper = new QueryWrapper<>();
        wrapper.eq("carid",carid);
        wrapper.eq("time",new Date());
        return reportMapper.selectCount(wrapper);
    }

    @Override
    public Integer updateRe(Report cReport) {
        return reportMapper.updateById(cReport);
    }

    @Override
    public Integer shoufei(ReportVo reportVo) {

        return reportMapper.upda(reportVo);
    }

    @Override
    public Integer guafei(ReportVo reportVo) {
        return cashierMapper.guafei(reportVo);
    }

    @Override
    public List<ReportVo> selhuan(ReportVo reportVo) {
        return reportMapper.selhuan(reportVo);
    }
}
